if (!jsx3.lang.Class.forName("tibco.admin.enterpriseAssets.userMgt.groups.UserSearchBar")) {
	jsx3.require("jsx3.gui.Block")
/**
*
*/
jsx3.lang.Package.definePackage("tibco.admin.enterpriseAssets.userMgt.groups", function (userSearchbar) {
});

/**
*
*/
jsx3.lang.Class.defineClass("tibco.admin.enterpriseAssets.userMgt.groups.UserSearchBar",
        jsx3.gui.Block,
        null,
        function (searchbar) {


				searchbar.prototype.initialize = function() {
                    // set the window instance id
                    if (jsx3.lang.Class.forName("tibco.admin.enterpriseAssets.userMgt.window.Window")) {
						this.windowObj = this.getAncestorOfType("tibco.admin.enterpriseAssets.userMgt.window.Window")
                        this.setWindowId(this.windowObj.getId());
                    }
					var me = this;
					this.searchBtn = this.getDescendantOfName("btnSearch_24_J_1");
					this.searchBtn.doSearch = function(key){
						me.doSearch(key);
					}
                }

				/**
				 *   set the current window ID
				 *   @para strId {string} The window id
				 */
				searchbar.prototype.setWindowId = function(strId) {
                    this.windowId = strId;
                }

				/**
				 *   get the current window ID
				 *   @return {string} The window id
				 */
                searchbar.prototype.getWindowId = function() {
                    return this.windowId;
                }


				/**
				 * This function is to show and hide the serach bar
				 */
				searchbar.prototype.show = function(objEvent){
                    var searchLayer = this.getDescendantOfName("blkBtm_24_J_1");
                    if((searchLayer.getVisibility() == jsx3.gui.Block.VISIBILITYHIDDEN)) {
                        searchLayer.setVisibility(jsx3.gui.Block.VISIBILITYVISIBLE, true);
                        this.getParent().setZIndex(2, true);
                    }
                    else {
                        searchLayer.setVisibility(jsx3.gui.Block.VISIBILITYHIDDEN, true);
                        this.getParent().setZIndex(0, true);
                    }
				}




				/**
				 *	To generate the search function and load the result dialog
				 */
				searchbar.prototype.doSearch = function(key){
					if(key.length==0)
						key = "*";
                    var loadTo = this.windowObj;
                    var body = tibco.admin.Main.getServer().getBodyBlock();
                    var parent = this.windowObj.getParent();
                    while(parent) {
                        if(parent == body) {
                            loadTo = body;
                            break;
                        }
                        parent = parent.getParent();
                    }
                    var addUserPopup = tibco.admin.Main.loadUIResource(loadTo,"tibco.admin","tibco/admin/enterpriseAssets/userMgt/window/groups/ui/addUsers.xml",true);
					addUserPopup.setWindow(this.windowObj)
                    var searchKeyword = addUserPopup.getDescendantOfName("txtKeyword_24_J_2");
					searchKeyword.setValue(key);
					addUserPopup.callsearchUsers();

                    var searchLayer = this.getDescendantOfName("blkBtm_24_J_1");
                    if((searchLayer.getVisibility() == jsx3.gui.Block.VISIBILITYVISIBLE))
                    {
                        searchLayer.setVisibility(jsx3.gui.Block.VISIBILITYHIDDEN, true);
						this.getParent().setZIndex(0, true);
                    }

				}




				/**
				 *	Search users - webservice call
				 */
				searchbar.prototype.callsearchUsers = function() {
				  var objService = APP.tibco.admin.loadResource("searchUsers_xml");
				  objService.setOperation("searchUsers");

				  objService.subscribe(jsx3.net.Service.ON_SUCCESS, this,this.onsearchUsersSuccess);
				  //objService.subscribe(jsx3.net.Service.ON_ERROR, this,this.onsearchUsersError);
				  //objService.subscribe(jsx3.net.Service.ON_INVALID, this,this.onsearchUsersInvalid);
				  objService.doCall();
				};

				searchbar.prototype.onsearchUsersSuccess = function(objEvent) {
				};

				searchbar.prototype.onsearchUsersError = function(objEvent) {
				  var myStatus = objEvent.target.getRequest().getStatus();
				  tibco.admin.util.Log.USERMGT.error("Error","The service call failed. The HTTP Status code is: " + myStatus);
				};

				searchbar.prototype.onsearchUsersInvalid = function(objEvent) {
				  tibco.admin.util.Log.USERMGT.error("Invalid","The following message node just failed validation:\n\n" + objEvent.message);
				};


        });
    }